import Vue from 'vue'
import VueRouter from 'vue-router'
import Home from "@/views/Home.vue";

Vue.use(VueRouter)

const routes = [
   {
    path:'/',
    redirect:"/home"
   },
   {
    path:'/home',
     meta:{
      cateShow:true
    },
    component:Home
   },
    {
    path:'/shop',
     meta:{
      cateShow:true
    },
    component:()=>import('@/views/Shop.vue')
   },
    {
    path:'/live',
     meta:{
      cateShow:true
    },
    component:()=>import('@/views/Live.vue')
   },
    {
    path:'/my',
     meta:{
      cateShow:true
    },
    component:()=>import('@/views/My.vue'),
    beforeEnter: (to, from, next) => {
        // 判断是否登录
       let login = window.sessionStorage.getItem("setToken");
       if (!login) {
          next("/login");
            return;
          } else {
            
            next();
          }
    }
   },
  // 搜索页
   {
    path:'/search',
     meta:{
      cateShow:false
    },
    component:()=>import('@/views/Search.vue')
   },
    // 分类页
   {
    path:'/cate',
    meta:{
      cateShow:false
    },
    component:()=>import('@/views/Cate.vue')
   },
  //  商品分类页
  {
    path:"/goodscategory",
    component:()=>import('@/views/Goodscategory.vue')
  },
  // 商品详情页
  {
    path:"/goodsdetails",
    component:()=>import('@/views/GoodSdetails.vue')
  },
  // 直播回放
  {
    path:"/videodetail",
    component:()=>import('@/views/Videodetail.vue')
  },
  // 登录页面
  {
    path:"/login",
    component:()=>import('@/views/Login.vue')
  },
  // 直播详情页
  {
    path:"/livedetails",
    component:()=>import('@/views/LiveDetails.vue')
  },
  // 相关资质页
  {
    path:"/certInfo",
    name:'certInfo',
    component:()=>import('@/views/CertInfo.vue')
  },
  // 购物车页面
  {
    path:"/shoppingcart",
    name:'shoppingcart',
    component:()=>import('@/views/Shoppingcart.vue')
  },
  // 订单页面
  {
    path:"/goodsorder",
    name:'goodsorder',
    component:()=>import('@/views/GoodsOrder.vue')
  },
   // 订单列表页
  {
    path:"/goodsorderlist",
    name:'goodsorderlist',
    component:()=>import('@/views/GoodsOrderList.vue')
  },
   // 用户关注页
  {
    path:"/focusOnTheUser",
    name:'focusOnTheUser',
    component:()=>import('@/views/FocusOnTheUser.vue')
  },
   // 商品收藏列表页
  {
    path:"/collectionList",
    name:'collectionList',
    component:()=>import('@/views/CollectionList.vue')
  }
]

const router = new VueRouter({
  mode: 'history',
  base: process.env.BASE_URL,
  routes
})

export default router
